package com.though.utils.tools;

import java.math.BigDecimal;

public class NumberUtils {

	
	/**
	 * 格式化
	 * @param value
	 * @param scale
	 * @return
	 */
	public static double keepScale(double value, int scale) {
		BigDecimal decimal = new BigDecimal(value);  
        return decimal.setScale(scale, BigDecimal.ROUND_HALF_UP).doubleValue(); 
	}
	
	
	
	/**
	 * 除法
	 * @return
	 */
	public static double divide(double value1, double value2, int scale) {
		BigDecimal bigDecimalDivide = new BigDecimal(value1).divide(new BigDecimal(value2), scale, BigDecimal.ROUND_HALF_UP);
		return bigDecimalDivide.doubleValue();
	}
}
